package com.example.demo.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.io.Serializable;
import javax.persistence.*;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import top.starp.util.CmdUtil;

/**
 * @description git_down
 * @author zhengkai.blog.csdn.net
 * @date 2022-06-06
 */
@Entity
@Builder
@AllArgsConstructor
@Data
@Table(name="git_down")
@ApiModel("git_down")
public class GitDown implements Serializable {

    private static final long serialVersionUID = 1L;

    public  void down() throws IOException {
//        CmdUtil.runCmd()
        String res = CmdUtil.downloadGitRepo(repoUrl, localDir);

        time=new Date();
    }


    @Id
    @ApiModelProperty("id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
    * id
    */
//    @ApiModelProperty("id")
//    @Column(name="id")
//    private Integer id;

    /**
    * repo_url
    */
    @ApiModelProperty("repo_url")
    @Column(name="repo_url")
    private String repoUrl;

    /**
    * local_dir
    */
    @ApiModelProperty("local_dir")
    @Column(name="local_dir")
    private String localDir;

    /**
    * time
    */
    @ApiModelProperty("time")
    @Column(name="time")
    private Date time;

    public GitDown() {
    }

}
